Есть желание использовать современные языковые фитчи, но переписывать код в ручную долго и скучно, тогда можно воспользоваться помощью искусственного интеллекта😄
Для того чтобы сделать свой код более современным используй следующий промпт:
Refactor the following code to modern [Тут напиши стандарт] programming standards:
[Сюда вставь свой код]
❗️Пример использования промпта:
Refactor the following code to modern c++23 programming standards:
int* createIntArray(int size) { int* arr = new int[size]; for (int i = 0; i < size; ++i) { arr[i] = i * i; } return arr; }
// Option 1: Return a std::vector (recommended for most cases) auto createIntArray(int size) -> std::vector<int> { std::vector<int> arr(size); std::ranges::generate(arr, [i = 0]() mutable { return i * i++; }); return arr; }
// Option 2: Return a std::unique_ptr (if you specifically need heap allocation) auto createIntArrayUnique(int size) -> std::unique_ptr<int[]> { auto arr = std::make_unique<int[]>(size); for (int i = 0; i < size; ++i) { arr[i] = i * i; } return arr; }
Это достаточно простой и быстрый способ привести код к текущему стандарту. К сожалению результат работы промпта всё де придётся проверить, так как текущая реализация AI далека от идеала, но даже так времени можно сэкономить массу.
👀 А как ты приводишь свой код к более современному виду? Делитесь в комментариях!
Есть желание использовать современные языковые фитчи, но переписывать код в ручную долго и скучно, тогда можно воспользоваться помощью искусственного интеллекта😄
Для того чтобы сделать свой код более современным используй следующий промпт:
Refactor the following code to modern [Тут напиши стандарт] programming standards:
[Сюда вставь свой код]
❗️Пример использования промпта:
Refactor the following code to modern c++23 programming standards:
int* createIntArray(int size) { int* arr = new int[size]; for (int i = 0; i < size; ++i) { arr[i] = i * i; } return arr; }
// Option 1: Return a std::vector (recommended for most cases) auto createIntArray(int size) -> std::vector<int> { std::vector<int> arr(size); std::ranges::generate(arr, [i = 0]() mutable { return i * i++; }); return arr; }
// Option 2: Return a std::unique_ptr (if you specifically need heap allocation) auto createIntArrayUnique(int size) -> std::unique_ptr<int[]> { auto arr = std::make_unique<int[]>(size); for (int i = 0; i < size; ++i) { arr[i] = i * i; } return arr; }
Это достаточно простой и быстрый способ привести код к текущему стандарту. К сожалению результат работы промпта всё де придётся проверить, так как текущая реализация AI далека от идеала, но даже так времени можно сэкономить массу.
👀 А как ты приводишь свой код к более современному виду? Делитесь в комментариях!
Telegram auto-delete message, expiring invites, and more
elegram is updating its messaging app with options for auto-deleting messages, expiring invite links, and new unlimited groups, the company shared in a blog post. Much like Signal, Telegram received a burst of new users in the confusion over WhatsApp’s privacy policy and now the company is adopting features that were already part of its competitors’ apps, features which offer more security and privacy. Auto-deleting messages were already possible in Telegram’s encrypted Secret Chats, but this new update for iOS and Android adds the option to make messages disappear in any kind of chat. Auto-delete can be enabled inside of chats, and set to delete either 24 hours or seven days after messages are sent. Auto-delete won’t remove every message though; if a message was sent before the feature was turned on, it’ll stick around. Telegram’s competitors have had similar features: WhatsApp introduced a feature in 2020 and Signal has had disappearing messages since at least 2016.
Библиотека C C разработчика | cpp boost qt from tr